package com.vertx.db;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise;
import io.vertx.redis.client.RedisAPI;
import io.vertx.redis.client.RedisOptions;
import io.vertx.redis.client.impl.RedisClient;

import java.util.ArrayList;
import java.util.List;

public class RedisVerticle extends AbstractVerticle {

	@Override
	public void start(Promise<Void> startPromise) throws Exception {

		RedisOptions redisOptions = new RedisOptions()
				.addConnectionString("redis://localhost:6379/0")
				.setMaxPoolSize(4)
				.setMaxPoolWaiting(16);
		RedisClient client = new RedisClient(vertx, redisOptions);

		RedisAPI redis = RedisAPI.api(client);

		List<String> l = new ArrayList<>();
		l.add("abc");
		l.add("1232323");
		redis.set(l);

		redis.get("abc", rs -> {
			if (rs.succeeded()) {
				System.out.println("abc=" + rs.result());
			} else {
				System.out.println("fail");
			}
		});


	}
}
